/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package test;

import java.util.Iterator;
import org.openymsg.network.FireEvent;
import org.openymsg.network.Status;
import org.openymsg.network.YahooUser;
import org.openymsg.network.event.SessionAdapter;
import org.openymsg.network.event.SessionAuthorizationEvent;
import org.openymsg.network.event.SessionChatEvent;
import org.openymsg.network.event.SessionConferenceEvent;
import org.openymsg.network.event.SessionErrorEvent;
import org.openymsg.network.event.SessionEvent;
import org.openymsg.network.event.SessionExceptionEvent;
import org.openymsg.network.event.SessionFileTransferEvent;
import org.openymsg.network.event.SessionFriendAcceptedEvent;
import org.openymsg.network.event.SessionFriendEvent;
import org.openymsg.network.event.SessionFriendFailureEvent;
import org.openymsg.network.event.SessionFriendRejectedEvent;
import org.openymsg.network.event.SessionGroupEvent;
import org.openymsg.network.event.SessionListEvent;
import org.openymsg.network.event.SessionNewMailEvent;
import org.openymsg.network.event.SessionNotifyEvent;
import org.openymsg.network.event.SessionPictureEvent;

/**
 *
 * @author phuctv
 */
public class MessageAdaptor extends SessionAdapter {

    @Override
    public void buzzReceived(SessionEvent event) {
        System.out.println(event.getFrom() + ":" + "BUZZ!!!!!!!");
    }

    @Override
    public void chatCaptchaReceived(SessionChatEvent ev) {
        System.out.println("chatCaptchaReceived");
    }

    @Override
    public void chatConnectionClosed(SessionEvent event) {
        System.out.println("chatConnectionClosed");
    }

    @Override
    public void chatExitReceived(SessionChatEvent event) {
        System.out.println("chatExitReceived");
    }

    @Override
    public void chatJoinReceived(SessionChatEvent event) {
        System.out.println("chatJoinReceived");
    }

    @Override
    public void chatMessageReceived(SessionChatEvent event) {
        System.out.println("chatMessageReceived");
    }

    @Override
    public void chatUserUpdateReceived(SessionChatEvent event) {
        System.out.println("chatUserUpdateReceived");
    }

    @Override
    public void conferenceInviteDeclinedReceived(SessionConferenceEvent event) {
        System.out.println("conferenceInviteDeclinedReceived");
    }

    @Override
    public void conferenceInviteReceived(SessionConferenceEvent event) {
        System.out.println("conferenceInviteReceived");
    }

    @Override
    public void conferenceLogoffReceived(SessionConferenceEvent event) {
        System.out.println("conferenceLogoffReceived");
    }

    @Override
    public void conferenceLogonReceived(SessionConferenceEvent event) {
        System.out.println("conferenceLogonReceived");
    }

    @Override
    public void conferenceMessageReceived(SessionConferenceEvent event) {
        System.out.println("conferenceMessageReceived");
    }

    @Override
    public void connectionClosed(SessionEvent event) {
        //It happens when logout
    }

    @Override
    public void contactAcceptedReceived(SessionFriendAcceptedEvent event) {
        System.out.println("contactAcceptedReceived");
        //happens when other accept adding request
    }

    @Override
    public void contactRejectionReceived(SessionFriendRejectedEvent event) {
        System.out.println("contactRejectionReceived");
        //happens when other deny adding request

    }

    @Override
    public void contactRequestReceived(SessionEvent event) {
        System.out.println("contactRequestReceived");
        System.out.println("FROM: " + event.getFrom());
        SessionAuthorizationEvent SAEvent = (SessionAuthorizationEvent) event;
        System.out.println(SAEvent.isAuthorizationAccepted());
        System.out.println(SAEvent.isAuthorizationDenied());
        System.out.println(SAEvent.isAuthorizationRequest());

    }

    @Override
    public void dispatch(FireEvent event) {
        super.dispatch(event);
    }

    @Override
    public void errorPacketReceived(SessionErrorEvent event) {
        System.out.println("errorPacketReceived");
    }

    @Override
    public void fileTransferReceived(SessionFileTransferEvent event) {
        System.out.println("fileTransferReceived");
    }

    @Override
    public void friendAddedReceived(SessionFriendEvent event) {
        System.out.println("friendAddedReceived");
        //happen when send a adding request to other
    }

    @Override
    public void friendRemovedReceived(SessionFriendEvent event) {
        System.out.println("friendRemovedReceived");
    }

    @Override
    public void friendsUpdateFailureReceived(SessionFriendFailureEvent event) {
        System.out.println("friendsUpdateFailureReceived");
        System.out.println(event.getFailure());
    }

    @Override
    public void friendsUpdateReceived(SessionFriendEvent event) {
        System.out.println("friendsUpdateReceived");
        System.out.println("GETFROM: " + event.getFrom() + " Status: " + event.getUser().getStatus().name());
    }

    @Override
    public void groupRenameReceived(SessionGroupEvent event) {
        System.out.println("groupRenameReceived");
    }

    @Override
    public void inputExceptionThrown(SessionExceptionEvent event) {
        System.out.println("inputExceptionThrown");
    }

    @Override
    public void listReceived(SessionListEvent event) {
        for (Iterator it = event.getContacts().iterator(); it.hasNext();) {
            YahooUser yuser = (YahooUser) it.next();
            if (yuser.getStatus() != Status.OFFLINE) {
                System.out.println("YUSER: "+yuser.getId());
            }
        }
    }

    @Override
    public void messageReceived(SessionEvent event) {
        System.out.println(event.getFrom() + ":" + event.getMessage());
    }

    @Override
    public void newMailReceived(SessionNewMailEvent event) {
        System.out.println(event.getFrom() + ":" + event.getSubject() + ":" + event.getEmailAddress());
    }

    @Override
    public void notifyReceived(SessionNotifyEvent event) {
        System.out.println("NotifyReceived");
    }

    @Override
    public void offlineMessageReceived(SessionEvent event) {
        System.out.println("offline message--" + event.getFrom() + ":" + event.getMessage());
    }

    @Override
    public void pictureReceived(SessionPictureEvent ev) {
        System.out.println("pictureReceived");

    }
}
